#include <string>

#include "redis_executor/redis_executor.h"
#include "redis_executor/scoped_reply.h"
#include "redis_executor/simple_redis_locator.h"

#include "ImServiceCommon_types.h"
#include "base/config_reader.h"

namespace imserver {

class RedisUserProfileAdapter {
 public:
  static RedisUserProfileAdapter & Instance() {
    ConfigReader cfg("../conf/user_profile_service.conf");
    static RedisUserProfileAdapter instance(new FixedLocator(cfg.Get("redis", "server_list")));
    return instance;
  }

  int Add(const UserProfile & user, int ttl);
  int BatchAdd(const UserProfileList & users);

  int Get(int64_t id, UserProfile * user);
  int BatchGet(const std::vector<int64_t> & ids, UserProfileMap * users);

 private:
  RedisExecutor redis_exec_;
  RedisUserProfileAdapter(RedisLocator * locator);
};

}

